package com.cswangdao.controller.user;

import com.cswangdao.domain.vo.WXGoodsDetailVo;
import com.cswangdao.domain.vo.WXGoodsRelatedVo;
import com.cswangdao.result.PageResult;
import com.cswangdao.result.Result;
import com.cswangdao.service.GoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wx/goods")
@Slf4j
public class WxGoodsController {

    @Autowired
    private GoodsService goodsService;

    @GetMapping("/detail")
    public Result<WXGoodsDetailVo> godsDatail(@RequestParam("id") Integer id){
        log.info("获取商品详情：id={}", id);
        WXGoodsDetailVo wxGoodsDetailVo = goodsService.getWxGoodsDetail(id);
        return Result.success(wxGoodsDetailVo);
    }


    @GetMapping("/related")
    public Result<PageResult<WXGoodsRelatedVo>> related(@RequestParam("id")Integer id){
        log.info("获取相关商品：id={}", id);
        PageResult<WXGoodsRelatedVo> pageResult = goodsService.getWxGoodsRelated(id);
        return Result.success(pageResult);
    }


}
